VB问题`请各位大虾帮忙

来源:百度知道 编辑:UC知道 时间:2024/06/07 09:48:43
小弟,新手`有个作业是:利用随即函数在label1上不停的显示小写字母,
如故label2.caption刚好为该字母,那这字母就变成红色```小弟急用`````多谢帮忙```````

楼上的你改完颜色不改回去了吗?简单改一下:

Private Sub Form_Load()
label2.caption="h"
End Sub

Private Sub Timer1_Timer()
Dim i As Integer
Randomize
i = Int((122 - 97 + 1) * Rnd + 97)
Label1.Caption = Chr(i)
If Label1.Caption = Label2.Caption Then
Label1.ForeColor = red
else
Label1.ForeColor = black
End If
End Sub